#pragma once
#include "Entity.h"
#include "Planets.h"
#include "AIStateMachine.h"
#include "../SGD Wrappers/SGD_Listener.h"
#include <string>

enum EType{ shabun, shadisc, shaflak, shike, shatent, shamancer };
enum State{ move, track, standBy };

class Projectile;
class animation;

class Enemy : public Entity, public SGD::Listener
{
public:
	Enemy(Entity* target);
	virtual ~Enemy();

	//Interface
	virtual void Update(float elapsedTime) override;
	virtual void Render() override;
	virtual int GetType() const override { return ENT_ENEMY; }
	virtual void HandleCollision(const IEntity* other) override;
	void HandleEvent(const SGD::Event* pEvent);

	virtual Entity* GetPlayer() const { return player; }
	virtual Planets * GetCurrentPlanet() const { return currentPlanet; }
	virtual void SetCurrentPlanet(Planets * inplanet) { currentPlanet = inplanet; }
	
	EType GetEType(){ return type; }
	State GetState(){ return state; }
	void SetEType(EType x){ type = x; }
	void SetState(State x){ state = x; }
	bool InRange(){ return inRange; }
	bool Flipped(){ return flipped; }
	float GetFireTimer(){ return fireTimer; }
	void SetFireTimer(float f) { fireTimer = f; }
	float waited = 0;
	void SetSpike(bool s = true){ spiked = s; }
	bool Spiked(){ return spiked; }
	SGD::Point GetHookPos(){ return hookPos; }
	float GetRange(){ return range; }
	void SetRange(float r){ range = r; }
	Planets*GetDestinationPlanet(){ return destPlanet; }
	void SetDestinationPlanet(Planets*p){ destPlanet = p; }
	bool GetFacingLeft(){ return FacingLeft; }
	void SetFacingLeft( bool f){ FacingLeft = f; }
protected:
	static AISM machine;
	int semitterID = 0;
	int shamitterID = 0;
	std::string spike;
	SGD::Point hookPos;
	bool flipped = false;
	bool spiked = false;
	float weaponCool;
	float range = 200;
	bool inRange = false;
	EType type = shabun;
	State state = State::move;
	float fireTimer = 0.0f;
	Entity* player = nullptr;
	Planets*currentPlanet = nullptr;
	Planets*destPlanet = nullptr;
	void Aggro();
	SGD::HTexture Tentacleimage = SGD::INVALID_HANDLE;
	animation * shabunImage = nullptr;
	animation * shaflackImage = nullptr;
	bool FacingLeft = false;

};

